package com.括号匹配深度;

import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		if (s.length() == 0) {
			System.out.println(0);
			return;
		} else {
			int count = 0;
			int max = 0;
			char a[] = s.toCharArray();
			for (int i = 0; i < a.length; i++) {
				if(a[i]=='(') {
					count++;
					max = Math.max(count, max);
				}
				if(a[i]==')') {
					count--;
				}
			}
			System.out.println(max);
		}
	}

}
// ((())())(((())(()))())
//(((()((((()))))())))
//                        ((6))